package com.sky.mapper.admin;


import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Employee;
import org.apache.ibatis.annotations.*;


public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * 查询返回一个对象
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 添加员工
     * @param employee
     */
     @Insert("insert into employee (name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user) " +
        "values (#{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
     @AutoFill(value = OperationType.INSERT)
    void save(Employee employee);

    /**
     * 分页查询
     * @param employeePageQueryDTO
     * @return
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 启用禁用员工状态
     * @param status
     * @param id
     * @return
     */
    @Update("update employee set status=#{status} where id=#{id}")

    int startOrStop(@Param("status") int status,@Param("id") int id);

    /**
     * 根据id查询,修改的前置回显
     * @param id
     * @return
     */
    Employee findOne(int id);

    /**
     * 根据修改
     * @param employee
     * @return
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateEmployee(Employee employee);
}
